//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        int[] nums={9,6,4,2,3,5,7,0,1};
        Solution solution = new Solution();
        System.out.println(solution.missingNumber(nums));
    }
}


class Solution {
    public int missingNumber(int[] nums) {
        int n = nums.length;
        boolean[] arr = new boolean[n + 1];
        for (int i = 0; i < nums.length; i++) {
            arr[nums[i]] = true;
        }
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == false) {
                return i;
            }
        }
        return -1;
    }
}